package com.dp.mallchat.common.user.dao;

import com.dp.mallchat.common.user.domain.entity.UserEmoji;
import com.dp.mallchat.common.user.domain.user.resp.UserEmojiResp;
import com.dp.mallchat.common.user.mapper.UserEmojiMapper;
import com.dp.mallchat.common.user.service.UserEmojiService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 用户表情包 服务实现类
 * </p>
 *
 * @author <a href="https://gitee.com/baiDP">adu</a>
 * @since 2024-07-18
 */
@Service
public class UserEmojiDao extends ServiceImpl<UserEmojiMapper, UserEmoji> {

    public List<UserEmojiResp> listEmojiByUid(Long uid) {
        List<UserEmoji> list = lambdaQuery()
                .eq(UserEmoji::getUid, uid)
                .list();
        return list.stream().map(item ->{
            return UserEmojiResp.builder()
                    .id(item.getId())
                    .expressionUrl(item.getExpressionUrl())
                    .build();
        }).collect(Collectors.toList());
    }
}
